/* Rexx program to convert .texinfo file to .html * * Also processes some amigaguide commands * * Only works on specific @commands!! * * SLOW * * $VER: texinfo2HTML.rexx 1.2 (2.2.94) * */ parse arg arg1 arg2 arg3 arg2 = strip(arg2) arg3 = strip(arg3) move = 0 if open('infile',arg1,'r') then do if open('texinfofile',arg3,'w') then do if open('outfile',arg2,'w') then do line = myreadln() do while ~eof('infile') if substr(line,1,1) = "@" then do w = upper(word(line,1)) select when w = "@@REMARK" then nop when w = "@@FONT" then nop when w = "@CINDEX" then nop when w = "@SETTITLE" then call writeln('outfile',""mystrip(delword(line,1,1))"") when w = "@PARAGRAPHINDENT" then nop when w = "@NODE" then do say line if upper(word(line,2)) ~= "TOP" then do call close('outfile') ts = delword(line,1,1) t = index(ts,",") if t>0 then arg2 = mystrip(left(ts,t-1))||".html" else arg2 = mystrip(ts)||".html" if ~open('outfile',arg2,'w') then do say "Error opening '"arg2"'" call close() return end end end when w = "@TOP" then do ts = mystrip(delword(line,1,1)) call writeln('outfile',""ts"") call writeln('outfile',"

"ts"

") call writeln('outfile',"
") up1 = "

" end when w = "@CHAPTER" then do ts = mystrip(delword(line,1,1)) call writeln('outfile',""ts"") call writeln('outfile',"

"ts"

") call writeln('outfile',"
") call writeln('outfile',up1) up2 = "

" end when w = "@UNNUMBEREDSEC" then do ts = mystrip(delword(line,1,1)) call writeln('outfile',""ts"") call writeln('outfile',"

"ts"

") call writeln('outfile',"
") call writeln('outfile',up2) up3 = "

" end when w = "@UNNUMBEREDSUBSEC" then do ts = mystrip(delword(line,1,1)) call writeln('outfile',""ts"") call writeln('outfile',"

"ts"

") call writeln('outfile',"
") call writeln('outfile',up3) up4 = "

" end when w = "@UNNUMBEREDSUBSUBSEC" then do ts = mystrip(delword(line,1,1)) call writeln('outfile',""ts"") call writeln('outfile',"

"ts"

") call writeln('outfile',"
") call writeln('outfile',up4) up5 = "

" end when w = "@UNNUMBERED" then do ts = mystrip(delword(line,1,1)) call writeln('outfile',""ts"") call writeln('outfile',"

"ts"

") call writeln('outfile',"
") call writeln('outfile',up5) up2 = "

" end when w = "@ITEMIZE" then call convertitemize() when w = "@EXAMPLE" then do call writeln('outfile',"

")
						line = myreadln()
						do while ~eof('infile') & (upper(line) ~= "@END EXAMPLE")
							call writeln('outfile',mystrip(line))
							line = myreadln()
						end
						call writeln('outfile',"
") end when w = "@MENU" then do line = myreadln() call writeln('outfile',"") do while ~eof('infile') & substr(line,1,1) ~= "*" call writeln('outfile',""line"") line = myreadln() end do while ~eof('infile') & upper(line) ~= "@END MENU" select when line = "" then call writeln('outfile',"

") when substr(line,1,1) = "*" then do if move>0 then do move = 0 call writeln('outfile',"") end call writech('outfile',"

  • ") /* One is NBSP */ call writeln('outfile',mystrip(strip(substr(line,3,index(line,":")-3),,"  "))||"") /* One is NBSP */ end when line = "" then call writeln('outfile',"

    ") otherwise if move=0 then do call writech('outfile',"

    ") end call writeln('outfile',"
  • ") end otherwise call writeln('outfile',myconvert(line)) end end else if line = "" then call writeln('outfile',"

    ") else call writeln('outfile',myconvert(line)) line = myreadln() end call close('outfile') end else say "Error opening '"arg2"'" call close('texinfofile') end else say "Error opening '"arg3"'" call close('infile') end else do say "Error opening '"arg1"'" end return mystrip: procedure parse arg line1 if index(line1,"@") > 0 then do line2 = "" do i=1 to length(line1) by 1 if substr(line1,i,1) = "@" then select when substr(line1,i,5) = "@ref{" then do line3 = substr(line1,i+5) line3 = substr(line3,1,index(line3,"}")-1) line2 = line2 || mystrip(substr(line3,index(line3,",")+1))||" " i = index(line1,"}",i) end when substr(line1,i,6) = "@xref{" then do line3 = substr(line1,i+6) line3 = substr(line3,1,index(line3,"}")-1) line2 = line2 || mystrip(substr(line3,index(line3,",")+1))||" " i = index(line1,"}",i) end when substr(line1,i,5) = '@@@{"' then do line3 = substr(line1,i+5) line3 = substr(line3,1,index(line3,"/Main")-1) line2 = line2 || mystrip(substr(line3,1,index(line3,"ALINK")-3))||" " i = index(line1,"}",i) end when substr(line1,i,7) = "@@@{u@}" then i = i+6 when substr(line1,i,8) = "@@@{uu@}" then i = i+7 when substr(line1,i,2) = "@@" then do line2 = line2 || "@" i = i + 1 end otherwise do j=i to length(line1) by 1 while substr(line1,j,1) ~= "{" nop end i = j end else if substr(line1,i,1) = "}" then nop else line2 = line2 || substr(line1,i,1) end return line2 end else return line1 myconvert: procedure parse arg line1 if index(line1,"@") > 0 then do line2 = "" do i=1 to length(line1) by 1 if substr(line1,i,1) = "@" then select when substr(line1,i,5) = "@ref{" then do line3 = substr(line1,i+5) line3 = substr(line3,1,index(line3,"}")-1) line2 = line2 || "" line2 = line2 || mystrip(substr(line3,index(line3,",")+1)) || "" i = index(line1,"}",i) end when substr(line1,i,6) = "@xref{" then do line3 = substr(line1,i+6) line3 = substr(line3,1,index(line3,"}")-1) line2 = line2 || "See " line2 = line2 || mystrip(substr(line3,index(line3,",")+1))||"" i = index(line1,"}",i) end when substr(line1,i,5) = '@@@{"' then do line3 = substr(line1,i+5) line3 = substr(line3,1,index(line3,"/Main")-1) line2 = line2 || "" line2 = line2 || mystrip(substr(line3,1,index(line3,"ALINK")-3))||"" i = index(line1,"}",i) end when substr(line1,i,7) = "@@@{u@}" then do i = i+6 line2 = line2 || "" end when substr(line1,i,8) = "@@@{uu@}" then do i = i+7 line2 = line2 || "" end when substr(line1,i,2) = "@@" then do line2 = line2 || "@" i = i + 1 end when upper(substr(line1,i,6)) = "@CODE{" then do line2 = line2 || "" do j=i+6 to length(line1) by 1 while substr(line1,j,1) ~= "}" line2 = line2 || substr(line1,j,1) end line2 = line2 || "" i = j end when upper(substr(line1,i,5)) = "@DFN{" then do line2 = line2 || "" do j=i+5 to length(line1) by 1 while substr(line1,j,1) ~= "}" line2 = line2 || substr(line1,j,1) end line2 = line2 || "" i = j end otherwise do j=i to length(line1) by 1 while substr(line1,j,1) ~= "{" nop end end else if substr(line1,i,1) = "}" then nop else line2 = line2 || substr(line1,i,1) end return line2 end else return line1 convertitemize: procedure expose line infile outfile call writeln('outfile',"

    ") return myreadln: procedure flag = 1 line = readln('infile') do while (flag>0) & ~eof('infile') if substr(line,1,1) = "@" then do w = upper(word(line,1)) select when w = "@HTML" then do call writeln('outfile',delword(line,1,1)) line = readln('infile') end when w = "@HTMLOFF" then do line = readln('infile') do while (word(line,1) ~= "@HTMLON") & ~eof('infile') call writeln('texinfofile',line) line = readln('infile') end if ~eof('infile') then line = readln('infile') end otherwise flag=0 end end else flag = 0 end call writeln('texinfofile',line) return line